package cate.game.play.buff.h;

import cate.game.play.buff.BuffHandler;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import easy.java.struct.ref.DoubleRef;

/**
 * 受到致死伤害时(斩杀和真实伤害除外),保留10%最大生命值并清除【风神】
 */
public class 风神BH extends BuffHandler {

	private double 血量;

	private int 风神眩晕buff;

	//血量=1000&风神眩晕buff=？？
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		血量 = args.getWDouble("血量", 0d);
		风神眩晕buff = args.getInt("风神眩晕buff", 0);
	}

	@Override
	public void adjustDeadlyDamage(ActionCtx action, Fighter actor, int reason, DoubleRef doubleRef) {
		double cur = buff.owner.attr.hpCur();
		double hpLeft = buff.owner.attr.total().hpTotal() * 血量;
		if (hpLeft < cur) {
			doubleRef.v = cur - hpLeft;
		} else {
			doubleRef.v = 0;
			buff.owner.attr.hpCur(hpLeft, action);
		}
		actor.buff.tryAddByTid(action, buff.owner, 风神眩晕buff);
		buff.markInvalid(action);
	}
}
